/*
* @Author: wanghongfucoder
* @Date:   2017-04-06 09:40:38
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-04-06 09:53:35
*/

import java.util.List;
import java.util.ArrayList;
public  class StudentImpl implements StudentDao {
	
	List<Student> students;

	public StudentImpl(){
		students=new ArrayList<Student>();
		Student student1=new Student("Robert",0);
		Student student2=new Student("john",1);
		students.add(student1);
		students.add(student2);
	}

	public void deleteStudent(Student student){
		students.remove(student.getRollNo());
		System.out.println("Student :  Roll No"+student.getRollNo()+",delete from database");
	}

	public List<Student> getAllStudent(){
		return students;
	}

	public Student getStudent(int rollNo){
		return students.get(rollNo);
	}

	public void updateStudent(Student student){
		students.get(student.getRollNo()).setName(student.getName());
		System.out.println("Student : Roll No "+student.getRollNo()+",updated in the database");
	}
}